home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Concept 6
/
CD Concept 06.iso
/
mac
/
UTILITAIRE
/
Little Smalltalk v3.1.4
/
C Source
/
Sources
/
CLStApp.cp
< prev
next >
Wrap
Text File
|
1995-01-26
|
6KB
|
217 lines
//=============================================================================
// Little Smalltalk, version 3
// Written by Tim Budd, Oregon State University, July 1988
//
// Symantec Think Class Library interface code
// ⌐Julian Barkway, April 1994, all rights reserved.
//
// CLStApp.cp
// ----------
// This class performs basic initialisation and other stuff relating to the
// Little Smalltalk TCL interface.
//=============================================================================
#include <string.h>
#include "CLStApp.h"
#include "CLStSwitchboard.h"
#include "CBartender.h"
#include "Global.h"
#include "Constants.h"
#include "Commands.h"
#include "LStResources.h"
extern OSType gSignature;
extern CBartender *gBartender;
#define kExtraMasters 10
#define kRainyDayFund 45000
#define kCriticalBalance 40000
#define kToolboxBalance 20000
CLStApp *gSmalltalk;
//=============================================================================
// Application initialization. Invoke IApplication to perform all ToolBox init
// calls, allocate memory and other stuff.
//=============================================================================
void CLStApp::ILStApp(void)
{
Handle versH;
CApplication::IApplication (kExtraMasters, kRainyDayFund,
kCriticalBalance, kToolboxBalance);
gSmalltalk = this;
ErrorSound (NULL); // Disable Alert beep
versH = GetResource ('vers', kVersionRes); // Get the version number
BlockMove ((*versH) + 6, versionStr, (Size)(*((*versH) + 6) + 1));
}
//=============================================================================
// Set up the types of files Li'l Smalltalk knows about as well as the
// application signature.
//=============================================================================
void CLStApp::SetUpFileParameters (void)
{
inherited::SetUpFileParameters();
sfNumTypes = kNumTypes; /* Number of file types in array (max 4) */
sfFileTypes [0] = kTextType; /* Text */
sfFileTypes [1] = kSysImageType; /* System Image files */
gSignature = kCreator;
}
//={OVERRIDE}==================================================================
// Store the command for interface processing
//=============================================================================
void CLStApp::DoCommand (long commandNo)
{
if (commandNo == cmdAbout) {
DoAbout (0L);
return;
}
if (commandNo < 0) {
menuID = HiShort (-commandNo);
menuItem = LoShort (-commandNo);
if (menuID == MENUapple) {
inherited::DoCommand (commandNo);
gSmalltalk->smalltalkCmd = FALSE;
return;
}
gSmalltalk->lastEvent.what = mouseDown; // Restore the action removed
// by LSTSwitchboard::GetAnEvent ()
gSmalltalk->smalltalkCmd = TRUE;
return;
}
// Must be a TCL command
if (commandNo == cmdQuit)
Quit ();
else {
menuID = 0;
inherited::DoCommand (commandNo);
gSmalltalk->smalltalkCmd = FALSE;
}
}
//={OVERRIDE}==================================================================
// Pass responsibility for quitting over to Smalltalk
//=============================================================================
Boolean CLStApp::Quit (void)
{
menuID = 0xffff;
gSmalltalk->smalltalkCmd = FALSE;
return true;
}
//={OVERRIDE}==================================================================
// Create application's switchboard. (Uses CLStSwtchboard)
//=============================================================================
void CLStApp::MakeSwitchboard (void)
{
itsSwitchboard = new (CLStSwitchboard);
itsSwitchboard->ISwitchboard ();
}
//=============================================================================
// Process a message alert
//=============================================================================
void CLStApp::DoMessageAlert (char *msg)
{
Str255 theString, errorStr;
short strID, itemID;
strcpy ((char *)errorStr, msg);
strcpy ((char *)theString, (char *)errorStr);
CtoPstr ((char *)theString);
ParamText (theString, NULL, NULL, NULL);
CautionAlert (k_OK_alert, NULL);
}
//=============================================================================
// Process a Yes, No, Cancel alert
//=============================================================================
short CLStApp::DoYNCAlert (char *msg)
{
Str255 theString, errorStr;
short strID, itemID;
InitCursor ();
strcpy ((char *)errorStr, msg);
strcpy ((char *)theString, (char *)errorStr);
CtoPstr ((char *)theString);
ParamText (theString, NULL, NULL, NULL);
itemID = CautionAlert (k_YNC_alert, NULL);
switch (itemID) {
case kSetButtonID:
return (1);
case kCancelButtonID:
return (-1);
case kNoButtonID:
return (0);
default: ;
}
}
//=============================================================================
// Put up the About Box
//=============================================================================
void CLStApp::DoAbout (long delay)
{
EventRecord theEvent;
GrafPtr savePort;
long ticksNow;
WindowPtr aboutWindow;
PicHandle aboutPic;
short sposX, sposY;
GetPort (&savePort);
aboutWindow = GetNewWindow (kAboutBoxWIND, NULL, (WindowPtr)-1L);
if (!aboutWindow)
return;
aboutPic = GetPicture (kAboutBoxPICT);
SetPort (aboutWindow);
DrawPicture (aboutPic, &aboutWindow->portRect);
TextFont (3); /* Geneva */
TextSize (9);
TextMode (srcXor);
sposX = StringWidth (versionStr);
sposX = ((aboutWindow->portRect.right - aboutWindow->portRect.left) / 2) - (sposX / 2);
sposY = aboutWindow->portRect.bottom - 20;
MoveTo (sposX, sposY);
DrawString (versionStr);
if (delay > 0L)
Delay (delay, &ticksNow);
else {
GetNextEvent (keyDownMask + mDownMask, &theEvent); /* Soak up any events */
/* left hanging around */
while (!GetNextEvent (keyDownMask + mDownMask, &theEvent))
SystemTask();
}
DisposeWindow (aboutWindow);
SetPort (savePort);
}
//={OVERRIDE}==================================================================
// Just copy the SFReply to an instance variable.
//=============================================================================
void CLStApp::OpenDocument (SFReply *macReply)
{
theFile = *macReply; // Save the SFReply for use later
}